﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="ToolStripItemAdapter.cs" company="">
//   
// </copyright>
// <summary>
//   The tool strip item adapter.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace Libium.Adapters
{
	using System;
	using System.Windows.Forms;
	using Libium.Core;
	using Libium.UseCases;
	using Libium.Views;

	/// <summary>
	/// The tool strip item adapter.
	/// </summary>
	/// <typeparam name="T">
	/// </typeparam>
	public class ToolStripItemAdapter<T> : IView
		 where T : ToolStripItem
	{
		#region Constructors and Destructors

		/// <summary>
		/// Initializes a new instance of the <see cref="ToolStripItemAdapter{T}"/> class.
		/// </summary>
		/// <param name="control">
		/// The control.
		/// </param>
		protected ToolStripItemAdapter(T control)
		{
			Control = control;
		}

		#endregion

		// TODO Remove ???
		#region Public Events

		/// <summary>
		/// The focused changed.
		/// </summary>
		public event Action<IView> FocusedChanged;

		/// <summary>
		///  Cancels wating process.
		/// </summary>
		public event Action<IView> WaitCancelled;

		#endregion

		#region Public Properties

		/// <summary>
		/// Gets or sets the copy source.
		/// </summary>
		public ICopySource CopySource { get; set; }

		/// <summary>
		/// Gets or sets a value indicating whether enabled.
		/// </summary>
		public bool Enabled
		{
			get
			{
				return Control.Enabled;
			}

			set
			{
				Control.Enabled = value;
			}
		}

		/// <summary>
		/// Gets a value indicating whether focused.
		/// </summary>
		public bool Focused
		{
			get
			{
				return false;
			}
		}

		/// <summary>
		/// Gets or sets the paste target.
		/// </summary>
		public IPasteTarget PasteTarget { get; set; }

		/// <summary>
		/// Gets or sets a value indicating whether read only.
		/// </summary>
		public virtual bool ReadOnly
		{
			get
			{
				return false;
			}

			set
			{
			}
		}

		/// <summary>
		/// Gets or sets a value indicating whether visible.
		/// </summary>
		public bool Visible
		{
			get
			{
				return Control.Visible;
			}

			set
			{
				Control.Visible = value;
			}
		}

		#endregion

		#region Properties

		/// <summary>
		/// Gets the control.
		/// </summary>
		protected T Control { get; private set; }

		#endregion

		#region Public Methods and Operators

		/// <summary>
		/// The clear.
		/// </summary>
		public virtual void Clear()
		{
		}

		/// <summary>
		/// The focus.
		/// </summary>
		/// <returns>
		/// The <see cref="bool"/>.
		/// </returns>
		public virtual bool Focus()
		{
			return false;
		}

		public void AddWarning(string warning)
		{
		}

		public void RemoveWarning()
		{
		}

		public void AddError(string warning)
		{
		}

		public void RemoveError()
		{
		}

		public void AddHint(string warning)
		{
		}

		public void RemoveHint()
		{
		}

		public void StartWait(IUseCase useCase)
		{
		}

		public void EndWait(IUseCase useCase)
		{
		}

		public void SetWaitProgress(IUseCase useCase)
		{

		}

		#endregion

		#region Methods

		/// <summary>
		/// The on focused changed.
		/// </summary>
		/// <param name="source">
		/// The source.
		/// </param>
		/// <param name="e">
		/// The e.
		/// </param>
		protected virtual void OnFocusedChanged(object source, EventArgs e)
		{
			if (FocusedChanged != null)
			{
				FocusedChanged(this);
			}
		}

		#endregion
	}
}